<?php


namespace app\common\validate;


use think\Validate;

/**
 * 银行类相关录入验证器
 * 2020年6月8日11:28:13
 * Class Bank
 * @package app\common\validate
 */
class Bank extends Validate {

    // 验证规则
    protected $rule = [
        'bank_name'     => 'require|min:6|max:100|unique:bank',
        'bank_abbr'     => 'require|max:12|unique:bank',
        'category_name' => 'require|min:6|max:100|unique:bank_pay_category',
        'bank_id'       => 'require'
    ];

    // 验证提示
    protected $message = [
        'bank_name.require'         => '名称必须',
        'bank_name.max'             => '名称最多不能超过50个字符',
        'bank_name.min'             => '名称最最少不能低于6个字符',
        'bank.unique'               => '银行名称已存在',
        'bank_abbr.require'         => '简称必须',
        'bank_abbr.max'             => '名称最多不能超过12个字符',
        'bank_abbr.unique'          => '银行简称已存在',
        'category_name.require'     => '类型名称必须',
        'category_name.min'         => '名称最最少不能低于6个字符',
        'category_name.max'         => '名称最多不能超过50个字符',
        'category_name.unique'      => '支付类型已存在',
        'bank_id.require'           => '所属银行ID必须',
    ];

    // 验证场景
    protected $scene = [
        'insert'            => ['bank_name','bank_abbr'],
        'update'            => ['bank_name','bank_abbr'],
        'category_insert'   => ['category_name','bank_id'],
        'category_update'   => ['category_name','bank_id'],
    ];

}
